<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:34:"./themes/admin/dp/application.html";i:1749696103;s:51:"/lysoo/syzth.lysoo.com/syzth/themes/admin/base.html";i:1741049647;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo $setup['title']; ?></title>
    <meta content="<?php echo $setup['keywords']; ?>" name="keywords" />
    <meta content="<?php echo $setup['description']; ?>" name="description" />
    <?php if($setup['ico'] != null): ?><link rel="shortcut icon" type="image/x-icon"  href="/public/uploads/<?php echo $setup['ico']; ?>"/><?php endif; ?>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
    <!--CSS引用-->
    
    <!--页面CSS-->
    <!--[if lt IE 9]>
    <script src="/public/static/js/html5shiv.min.js"></script>
    <script src="/public/static/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">家政服务申请管理</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form" action="">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <input type="text" name="name" placeholder="请输入联系人姓名" value="<?php echo $name; ?>" class="layui-input">
                            </div>
                            <div class="layui-inline">
                                <select name="type">
                                    <option value="">全部类型</option>
                                    <option value="日常清洁" <?php if($type=='日常清洁'): ?>selected<?php endif; ?>>日常清洁</option>
                                    <option value="烹饪膳食" <?php if($type=='烹饪膳食'): ?>selected<?php endif; ?>>烹饪膳食</option>
                                    <option value="家电清洁" <?php if($type=='家电清洁'): ?>selected<?php endif; ?>>家电清洁</option>
                                </select>
                            </div>
                            <div class="layui-inline">
                                <select name="status">
                                    <option value="">全部状态</option>
                                    <option value="0" <?php if($status==='0'): ?>selected<?php endif; ?>>待审核</option>
                                    <option value="1" <?php if($status==='1'): ?>selected<?php endif; ?>>已审核</option>
                                    <option value="2" <?php if($status==='2'): ?>selected<?php endif; ?>>已拒绝</option>
                                    <option value="3" <?php if($status==='3'): ?>selected<?php endif; ?>>已完成</option>
                                </select>
                            </div>
                            <div class="layui-inline">
                                <button class="layui-btn" lay-submit>搜索</button>
                            </div>
                        </div>

                        <table class="layui-table" lay-size="sm">
                            <thead>
                                <tr>
                                    <!--<th>ID</th>-->
                                    <th>联系人</th>
                                    <th>身份证</th>
                                    <th>联系电话</th>
                                       <th>社区</th>
                                          <th>街道</th>
                                    <th>地址</th>
                                    <th>孩子姓名</th>
                                    <th>孩子身份证</th>
                                    <th>出生证明</th>
                                    <!--<th>服务类型</th>-->
                                    <!--<th>截至时间</th>-->
                                    <th>备注</th>
                                    <!--<th>申请人员</th>-->
                                    <!-- <th>审核人员</th>-->
                                     <th>审核日期</th>
                                     <th>申请日期</th>
                                    <th>状态</th>
                                    <th style="width: 120px;">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php if(is_array($list) || $list instanceof \think\Collection || $list instanceof \think\Paginator): if( count($list)==0 ) : echo "" ;else: foreach($list as $key=>$vo): ?>
                                <tr>
                                    <!--<td><?php echo $vo['id']; ?></td>-->
                                    <td><?php echo $vo['name']; ?></td>
                                    <td><?php echo $vo['id_card']; ?></td>
                                    <td><?php echo $vo['phone']; ?></td>
                                      <th><?php echo $vo['jiedao']; ?></th>
                                          <th><?php echo $vo['shequ']; ?></th>
                                    <td><?php echo $vo['address']; ?></td>
                                    <td><?php echo $vo['child_name']; ?></td>
                                    <td><?php echo $vo['child_id_card']; ?></td>
                                    <!-- <td>-->
                                    <!--  <?php if($vo['birth_cert']): ?>-->
                                    <!--    <div class="photo-box" style="cursor:pointer;" data-pic="<?php echo $vo['birth_cert']; ?>">-->
                                    <!--   <img src="<?php echo $vo['birth_cert']; ?>" layer-pid="" layer-src="<?php echo $vo['birth_cert']; ?>" alt="出生证明" style="max-width: 60px; max-height: 60px; border-radius: 4px; border: 1px solid #ccc;" />-->

                                    <!--    </div>-->
                                    <!--  <?php else: ?>-->
                                    <!--    <span style="color: #ccc;">未上传</span>-->
                                    <!--  <?php endif; ?>-->
                                    <!--</td>-->
                                    
                                                <td>
                                        <?php if($vo['birth_cert']): ?>
                                        <div class="photo-box" style="cursor:pointer;">
                                            <img src="<?php echo $vo['birth_cert']; ?>" alt="出生证明" class="custom-img" style="max-width: 60px; max-height: 60px; border-radius: 4px; border: 1px solid #ccc;" />
                                        </div>
                                        <?php else: ?>
                                        <span style="color: #ccc;">未上传</span>
                                        <?php endif; ?>
                                    </td>
                                    <!--<td><?php echo $vo['type']; ?></td>-->
                                    <!--<td><?php echo date('Y-m-d', $vo['end_time']); ?></td>-->
                                    <td><?php echo $vo['note']; ?></td>
                                    <!--<td><?php echo $vo['create_name']; ?></td>-->
                                    <!--   <th><?php echo $vo['admin_name']; ?></th>-->
                                     <th><?php echo $vo['application_time']; ?></th>
                                      <th><?php echo $vo['create_time']; ?></th>
                                    <td>
                                        <?php if($vo['status'] == 0): ?>
                                            <span style="color:#FFB800;">待审核</span>
                                        <?php elseif($vo['status'] == 1): ?>
                                            <span style="color:green;">已审核</span>
                                        <?php elseif($vo['status'] == 2): ?>
                                            <span style="color:red;">已拒绝</span>
                                        <?php elseif($vo['status'] == 4): ?>
                                            <span style="color:gray;">已完成</span>
                                        <?php endif; ?>
                                    </td>
                                   <td>
                                        <div class="layui-btn-group">
                                            <!-- 状态为 0：显示审核和拒绝 -->
                                            <?php if($vo['status'] == 0): ?>
                                                <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-normal approve-btn" data-id="<?php echo $vo['id']; ?>" title="审核通过"><i class="layui-icon">&#xe605;</i></a>
                                                <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger reject-btn" data-id="<?php echo $vo['id']; ?>" title="拒绝审核"><i class="layui-icon">&#x1006;</i></a>
                                            <?php endif; ?>
                                    
                                            <!-- 状态为 1（已审核）：显示废单 -->
                                            <?php if($vo['status'] == 1): ?>
                                                <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-warm discard-btn" data-id="<?php echo $vo['id']; ?>" title="废单"><i class="layui-icon">&#x1006;</i></a>
                                            <?php endif; ?>
                                    
                                            <!-- 状态为 2（已拒绝）：显示初始化 -->
                                            <?php if($vo['status'] == 2): ?>
                                                <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-primary reset-btn" data-id="<?php echo $vo['id']; ?>" title="初始化"><i class="layui-icon">&#xe669;</i></a>
                                            <?php endif; ?>
                                    
                                            <!-- 所有状态都能查看 -->
                                            <!--<a href="<?php echo url('admin/jzfw/view_application',['id'=>$vo['id']]); ?>" class="layui-btn layui-btn-sm" title="查看"><i class="layui-icon">&#xe63c;</i></a>-->
                                        </div>
                                    </td>
                                </tr>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="image-viewer" style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.8); justify-content:center; align-items:center; z-index:9999; flex-direction: column;">
    <img id="viewer-img" src="" style="max-width:80%; max-height:80%; transition: transform 0.3s ease;" />
    <!--<div style="margin-top: 20px;">-->
    <!--    <button id="rotate-btn" style="margin-right: 10px;z-index:1000">旋转</button>-->
    <!--    <button id="close-btn" style="z-index:1000">关闭</button>-->
    <!--</div>-->
    
    <div style="position: absolute; bottom: 40px; z-index: 1001; display: flex; gap: 10px; justify-content: center; width: 100%;">
    <button id="rotate-btn">旋转</button>
    <button id="close-btn">关闭</button>
</div>
</div>

<div class="pagination-wrapper">
    <?php echo $applications->render(); ?>
</div>

<!--页面-->

<!--JS引用-->
<script src="/public/static/js/jquery.min.js"></script>
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: "lib/index" //主入口模块
    }).use('index');
</script>

<script>
layui.use(['layer', 'form'], function(){
    //   setTimeout(function () {
    //   layer.photos({
    //     photos: '.layui-table',
    //     anim: 5
    //   });
    // }, 100);
    
    
    var $ = layui.jquery, layer = layui.layer, form = layui.form;

    // 审核通过按钮事件
    $('.approve-btn').on('click', function () {
        var id = $(this).data('id');
        layer.confirm('确认审核通过？操作后无法撤销！', {
            icon: 3, title: '提示'
        }, function(index){
            $.get('<?php echo url("admin/dp/approve_application"); ?>?id=' + id, function(res){
                layer.msg(res.msg);
                if (res.code === 1) location.reload();
            });
            layer.close(index);
        });
    });

    // 拒绝审核按钮事件
$('.reject-btn').on('click', function () {
    var id = $(this).data('id');
    layer.open({
        type: 1,
        title: '拒绝理由',
       area: ['520px', '360px'],
        content: `
            <div style="padding: 20px;">
                <form class="layui-form" lay-filter="rejectForm">
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 100px;">拒绝原因</label>
                        <div class="layui-input-block" style="margin-left: 120px;">
                            <select name="reason" lay-verify="required">
                                <option value="">请选择原因</option>
                         <option value="">请选择拒绝理由</option>
                        <option value="出生医学证明图片不清晰">出生医学证明图片不清晰</option>
                        <option value="现居地住址不符合要求">现居地住址不符合要求</option>
                        <option value="孩子出生年月不符合要求">孩子出生年月不符合要求</option>
                        <option value="信息不明确">信息不明确</option>
                        <option value="其他">其他</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 100px;">补充说明</label>
                        <div class="layui-input-block" style="margin-left: 120px;">
                            <textarea name="reason_note" placeholder="例如：所在地区+街道+村+小区，备注精确到门牌号" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item" style="text-align: right;">
                        <button type="button" class="layui-btn layui-btn-danger confirm-reject" data-id="${id}">确认拒绝</button>
                    </div>
                </form>
            </div>
        `,
        success: function () {
            form.render();
        }
    });
});
    
 $('.discard-btn').on('click', function () {
    var id = $(this).data('id');
    layer.open({
        type: 1,
        title: '废单理由',
        area: ['520px', '360px'],
        content: `
            <div style="padding: 20px;">
                <form class="layui-form" lay-filter="discardForm">
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 100px;">废单原因</label>
                        <div class="layui-input-block" style="margin-left: 120px;">
                            <select name="reason" lay-verify="required">
                                <option value="">请选择原因</option>
                                <option value="地址不在辖区内">地址不在辖区内</option>
                                <option value="出生证明无法识别">出生证明无法识别</option>
                                <option value="家庭住址不详细">家庭住址不详细</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 100px;">补充说明</label>
                        <div class="layui-input-block" style="margin-left: 120px;">
                            <textarea name="reason_note" placeholder="例如：所在地区+街道+村+小区，备注精确到门牌号" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item" style="text-align: right;">
                        <button type="button" class="layui-btn layui-btn-warm confirm-discard" data-id="${id}">确认废单</button>
                    </div>
                </form>
            </div>
        `,
        success: function () {
            form.render();
        }
    });
});
$(document).on('click', '.confirm-discard', function () {
    var id = $(this).data('id');
    var reasonType = $('select[name="reason"]').val();
    var reason = $('textarea[name="reason_note"]').val().trim();

    if (!reasonType) {
        return layer.msg('请选择废单原因');
    }

    layer.confirm('确认废单？操作后无法恢复！', {
        icon: 3, title: '提示'
    }, function (index) {
        $.post('<?php echo url("admin/dp/discard_application"); ?>', {
            id: id,
            reason_type: reasonType,
            reason: reason
        }, function (res) {
            layer.msg(res.msg);
            if (res.code === 1) location.reload();
        });
        layer.closeAll();
    });
});
window.onload = function () {
    const viewer = document.getElementById('image-viewer');
    const img = document.getElementById('viewer-img');
    const rotateBtn = document.getElementById('rotate-btn');
    const closeBtn = document.getElementById('close-btn');
    let currentRotation = 0;

    document.querySelectorAll('.custom-img').forEach(function (el) {
        el.addEventListener('click', function () {
            img.src = el.src;
            currentRotation = 0;
            img.style.transform = 'rotate(0deg)';
            viewer.style.display = 'flex';
        });
    });

    rotateBtn.addEventListener('click', function () {
        currentRotation += 90;
        img.style.transform = 'rotate(' + currentRotation + 'deg)';
    });

    closeBtn.addEventListener('click', function () {
        viewer.style.display = 'none';
    });

    viewer.addEventListener('click', function (e) {
        if (e.target === viewer) {
            viewer.style.display = 'none';
        }
    });
};
    // 初始化操作
    $('.reset-btn').on('click', function () {
        var id = $(this).data('id');
        layer.confirm('确认将此申请状态重置为待审核？', {
            icon: 3, title: '提示'
        }, function(index){
            $.post('<?php echo url("admin/dp/reset_application"); ?>', {id: id}, function(res){
                layer.msg(res.msg);
                if (res.code === 1) location.reload();
            });
            layer.close(index);
        });
    });
    
    // 提交拒绝操作
   $(document).on('click', '.confirm-reject', function () {
         var id = $(this).data('id');
    var reasonType = $('select[name="reason"]').val();
    var reason = $('textarea[name="reason_note"]').val().trim();

    if (!reasonType) {
        return layer.msg('请选择拒绝原因');
    }

    layer.confirm('确认拒绝？操作后无法撤销！', {
        icon: 3, title: '提示'
    }, function(index){
        $.post('<?php echo url("admin/dp/reject_application"); ?>', {
            id: id,
            reason_type: reasonType,
            reason: reason
        }, function(res){
            layer.msg(res.msg);
            if (res.code === 1) location.reload();
        });
        layer.closeAll(); // 关闭所有弹窗
    });
    });
});
</script>
<style>.pagination-wrapper {
    text-align: center;
    margin: 20px 0;
}
#image-viewer button {
    background: #fff;
    border: none;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
}
#image-viewer button:hover {
    background: #eee;
}
</style>

<!--页面JS脚本-->
</body>
</html>

